<template>
	<view class="add-input">
		<!-- 自定义导航栏 -->
		<uni-nav-bar :statusBar="true" rightText="发布" left-icon="arrowleft" @clickLeft="back" @clickRight="submit">
			<view class="uflex-a-j_c" style="width: 100%;" @tap="changelook">
				{{yinsi}}<text class="icon iconfont icon-xialazhankai"></text>
			</view>
		</uni-nav-bar>
		<!-- 多行输入框 -->
		<view class="uni-textarea">
			<textarea auto-height maxlength="200" v-model="textarea" placeholder="说一句话吧~~" />
		</view>
		<!-- 上传多图 -->
		<upload-images @upload="upload"></upload-images>
		
		<!-- 弹出公告 -->
		<uni-popup :show="showPopup" position="middle" mode="fixed" @hidePopup="hidePopup">
			<view class="gonggao">
				<view class="uflex-a-j_c">
					<image src="../../static/common/addinput.png" mode="widthFix"></image>
				</view>
				<view class="gonggao-title">1、涉及黄色，政治、广告及骚扰信息</view>
				<view class="gonggao-title">2、涉及人身攻击</view>
				<view class="gonggao-title">3、留联系方式，透露他人隐私</view>
				<view class="gonggao-title">一经核实将被封禁，情节严重永久封禁</view>
				<button type="primary" @tap="hidePopup">朕知道了</button>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	let changelooks = ['所有人可见', '仅自己可见'];
	import uniNavBar from '../../components/uni-nav-bar/uni-nav-bar.vue';
	import uploadImages from '../../components/common/upload-images.vue';
	import uniPopup from '../../components/uni-popup/uni-popup.vue';
	export default {
		data() {
			return {
				yinsi: '所有人可见',
				textarea: '',
				imageList: [],
				showPopup: true,
				isget: false
			}
		},
		methods: {
			// 返回
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			// 发布
			submit() {
				
			},
			// 隐私
			changelook(){
				uni.showActionSheet({
					itemList: changelooks,
					success: (res) => {
						this.yinsi = changelooks[res.tapIndex]
					}
				})
			},
			upload(imagesarr){
				this.imageList = imagesarr
			},
			hidePopup(){
				this.showPopup = false
			},
			// 保存为草稿
			baocu() {
				uni.showModal({
					content:'是否要保存为草稿',
					cancelText:"不保存",
					confirmText:'保存',
					success: res => {
						if(res.confirm){
							console.log("保存")
						}else{
							console.log("不保存")
						}
						this.isget = true
						this.back()
					}
				})
			}
		},
		components:{
			uniNavBar,
			uploadImages,
			uniPopup
		},
		onBackPress() {
			if(!this.textarea && this.imageList.length < 1){return}
			if(!this.isget){
				this.baocu()
				return true
			}
		}
	}
</script>

<style scoped lang="scss">
.add-input{
	width:100%;
	.uni-textarea{
		width: 100%;
		min-height: 200upx;
		border-bottom: 1upx solid #f5f5f5;
	}
	.gonggao{
		width: 560upx;
		image{
			width:90%;
		}
		.gonggao-title{
			padding: 0 20upx;
			font-size: 30upx;
			font-weight: 400;
			color: #040000;
			&:last-of-type{
				margin-bottom: 20upx;
			}
		}
		>button{
			background-color: #ffe934;
			color: #171606;
		}
	}
}
</style>
